package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.NoticeAffiche;
import com.zygh.policeasset.pojo.NoticeAfficheVO;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/mapper/NoticeAfficheMapper.class */
public interface NoticeAfficheMapper {
    @Select({"<script>select na.*,af.app_status,af.flow_no,u.name as userName from notice_affiche na left join audit_flow af on na.flow_no = af.flow_no left join user u on na.user_id = u.id <where><if test='send != null '>na.send=#{send}  </if><if test='type != null '>and na.type=#{type}  </if><if test='userId != null '> and af.applicant=#{userId} </if><if test=' status != null'> and af.app_status = #{status} </if></where>order by na.id desc</script>"})
    @Results(id = "map", value = {@Result(property = "creatTime", column = "creat_time"), @Result(property = "sendTime", column = "send_time"), @Result(property = "appStatus", column = "app_status"), @Result(property = "flowNo", column = "flow_no"), @Result(property = "userId", column = "user_id")})
    List<NoticeAfficheVO> findAll(NoticeAffiche noticeAffiche);

    @Select({"<script>SELECT  na.*  FROM  notice_affiche na  LEFT JOIN notice_affiche_user nau ON na.id = nau.notice_affiche_id   LEFT JOIN audit_flow af ON na.flow_no = af.flow_no <where><if test='appStatus != null '>and af.app_status=#{appStatus}  </if><if test='userId != null '>and nau.user_id=#{userId} </if><if test='type != null '>and na.type=#{type} </if><if test='status != null '>and nau.status=#{status} </if></where>order by na.id desc</script>"})
    @ResultMap({"map"})
    List<NoticeAfficheVO> findAllByUserId(@Param("appStatus") Integer num, @Param("userId") Integer num2, @Param("type") Integer num3, @Param("status") Integer num4);

    @Select({"<script>SELECT  count(*)  FROM  notice_affiche_user nau  <where><if test='userId != null '>and nau.user_id=#{userId} </if><if test='status != null '>and nau.status=#{status} </if></where>order by nau.id desc</script>"})
    Integer queryCount(@Param("appStatus") Integer num, @Param("userId") Integer num2, @Param("status") Integer num3);

    @Select({"<script>select na.*,af.app_status,af.flow_no,u.name as userName from notice_affiche na left join audit_flow af on na.flow_no = af.flow_no left join user u on na.user_id = u.id <where><if test='id != null '>na.id=#{id}  </if></where></script>"})
    @ResultMap({"map"})
    NoticeAfficheVO SelectById(Integer num);

    @Insert({"insert into notice_affiche (title,content,sender,grade,creat_time,send_time,type,send,users,flow_no,user_id) values (#{title},#{content},#{sender},#{grade},#{creatTime},#{sendTime},#{type},#{send},#{users},#{flowNo},#{userId})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    Integer add(NoticeAffiche noticeAffiche);

    @Update({"<script>update notice_affiche <set> <if test='title != null and title.length &gt; 0'>title = #{title}, </if><if test='content != null and content.length &gt; 0'>content = #{content}, </if><if test='sender != null '>sender = #{sender}, </if><if test='grade != null'>grade = #{grade}, </if><if test='sendTime != null and sendTime.length &gt; 0'>send_time = #{sendTime}, </if><if test='send != null'>send = #{send}, </if></set> where id = #{id}</script>"})
    Integer update(NoticeAffiche noticeAffiche);

    @Delete({"delete from notice_affiche where id=#{id}"})
    Integer delete(int i);

    @Select({"select na.*,af.app_status as status from notice_affiche na left join audit_flow af on na.flow_no = af.flow_no where na.id=#{id}"})
    NoticeAffiche selectById(int i);
}